﻿using System;
using SilverChart.Core.Configuration;
using SilverChart.Core.Service;

namespace SilverChart.Configuration.Converter {
    [ServiceProvider(LayzeCreation = true, ServiceName = "Default ChartType configuration converter", Singleton = true)]
    public class ChartTypesConverter : ConfigurationConverter<ChartType> {
        public Boolean Convert(string input, out ChartType value) {
            switch (input.ToLower()) {
                case "line":
                    value = ChartType.Line;
                    break;
                case "dot":
                    value = ChartType.Dot;
                    break;
                case "bar":
                    value = ChartType.Bar;
                    break;
                case "pie":
                    value = ChartType.Pie;
                    break;
                default:
                    value = ChartType.Unknown;
                    return false;
            }
            return true;
        }
    }
}
